//
//  DiaryBookViewController.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/16.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "DiaryBookViewController.h"
#import "DiaryCell.h"
#import "DiaryDetailViewController.h"

@interface DiaryBookViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *diaryTable;

@end

@implementation DiaryBookViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLab.text = @"日记集";
    
    [self setViews];
}

- (void)setViews {
    self.diaryTable  = [[UITableView alloc] init];
//                        initWithFrame:CGRectMake(0, CGRectGetMaxY(self.headerImgV.frame), kScreenWidth, kScreenHeight - CGRectGetMaxY(self.headerImgV.frame)) style:UITableViewStylePlain];
    [self.view addSubview:self.diaryTable];
    [self.diaryTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerImgV.mas_bottom);
        make.left.right.bottom.equalTo(@0);
    }];

    self.diaryTable.delegate = self;
    self.diaryTable.dataSource = self;
    [self.diaryTable  registerNib:[UINib nibWithNibName:@"DiaryCell" bundle:nil] forCellReuseIdentifier:@"diaryCell"];
//    self.diaryTable.backgroundColor = [UIColor cyanColor];
    self.diaryTable.separatorStyle = UITableViewCellSeparatorStyleNone;
}

#pragma mark -  tableview代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DiaryCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"diaryCell" forIndexPath:indexPath];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    DiaryDetailViewController *diaryDetail = [[DiaryDetailViewController alloc] init];
    diaryDetail.modalTransitionStyle = 2;
    [self presentViewController:diaryDetail animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
